import java.util.StringTokenizer;

public class TestStringTokenizer {
    public static void main(String[] args) {
        String s = "牛奶:89.8元, 香肠:12.9元 啤酒:69元 巧克力:132元";
        String regex = "[^1234567890.]+";
        String digiMess = s.replaceAll(regex,"*");
        StringTokenizer fenxi = new StringTokenizer(digiMess,"*");
        int number = fenxi.countTokens();
        double sum = 0;
        while(fenxi.hasMoreTokens()){
            String str = fenxi.nextToken();
            System.out.println(str);
            sum = sum + Double.parseDouble(str);
        }
        System.out.println("购物小票中的商品种类："+number+"种");
        System.out.println("购物小票种的价格总额："+sum+"元");
    }
}
